(function(factory, window){
  "use strict";
  if (typeof define === 'function' && define.amd) {
    define(['leaflet'], factory);
  } else if (typeof exports === 'object') {
    module.exports = factory(require('leaflet'));
  }
  if (typeof window !== 'undefined' && window.L) {
    window.L.IconControl = factory(L);
  }
}(function (L) {
  "use strict";
  L.Control.IconControl = L.Control.extend({
    options: {
      position: 'topright',
      type: '',
      iconClass: 'el-icon-warning',
      title: ''
    },
    onAdd: function(map) {
      this._map = map;
      this._container = L.DomUtil.create('a', 'leaflet-bar');
      this._container.title = this.options.title;
      this._container.style = 'width:30px;height:30px;background-color:#fff;display:flex;align-items:center;justify-content:center;font-size:18px;color:#666;';
      this._icon = L.DomUtil.create('i', this.options.iconClass, this._container);
      L.DomEvent.on(this._container, 'click', this._buttonClicked, this);
      return this._container;
    },
    onRemove: function() {
      L.DomEvent.off(this._container, 'click', this._buttonClicked, this);
    },
    _buttonClicked: function() {
      this._map.fire('icon:' + this.options.type);
    },
    _clicked: function(e) {

    }
  });
  L.control.iconcontrol = function(options) {
    return new L.Control.IconControl(options);
  };
}, window));
